import axios from "axios"

const put = (url, arg) =>{
  return new Promise((resolve , reject)=>{
    axios({
        method: "put",
        url: url,
        data: arg,
        headers: {
          "Content-Type":"text/html"
        }
    })
        .then(res=>{
          resolve(res.data);
        })
        .catch(()=>{
          reject("put请求链接失败")
      });
  });
};
const dele = (url, arg) =>{
  return new Promise((resolve, reject)=>{
    axios
      .delete(url,{
        params: arg
      })
      .then(
        res =>{
          resolve(res.data);
        },
        ()=>{
          reject("dele请求链接失败");
        }
      );
  });
};
const get = (url, arg) =>{
  return new Promise((resolve, reject)=>{
    axios
        .get(url,{
          params: arg
            //witchCredentials: true
        })
        .then(
            res =>{
              resolve(res.data);
            },
            ()=>{
              reject("get请求链接失败")
            }
        );
  });
};
const post = (url, arg) =>{
  return new Promise((resolve, reject)=>{
    axios({
        method:"post",
        url: url,
        data: arg,
        headers: {
            "Content-Type":"text/html"
        }
    })
  })
};

export default {
  //登录
  put,
  dele,
  get,
  post,
}
